package com.dhp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @ClassName: SwaggerConfig
 * @Description: TODO
 * @Author: dhp
 * @Date: 2020/12/6 15:00
 * @Version: v1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dhp.controller"))   //controller的路径
                .paths(PathSelectors.any())    //所有路径都生成文档
                .build().apiInfo(new ApiInfoBuilder()    //配置网站基本信息
                        .description("接口文档的描述信息")
                        .title("项目接口文档")
                        .version("v1.0")
                        .license("Apache2.0")
                        .build());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("springboot利用swagger2构建api文档")
                .description("简单优雅的restful风格，http://blog.csdn.net/saytime")
                .version("1.0")
                .build();
    }
}
